package com.alan.controller;

import com.alan.entity.LoginUser;
import com.alan.entity.RestBean;
import com.alan.entity.dto.VocabularyLearnDto;
import com.alan.service.VocabularyService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.springframework.data.relational.core.sql.In;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/vocabulary")
public class VocabularyController {

    @Resource
    private VocabularyService vocabularyService;


    @GetMapping("/getLists")
    public RestBean getLists(){
        return this.vocabularyService.getList();
    }

    @GetMapping("/learn")
    public RestBean goLearn(@RequestParam("listId") Integer listId,
                            @RequestParam("userId") Integer userId){

        return this.vocabularyService.goLearn(listId, userId);
    }

    @GetMapping("/getReviseList")
    public RestBean getReviseList(@RequestParam("userId") Integer userId){

        return this.vocabularyService.getReviseList(userId);
    }


    @PostMapping("/updateReviseList")
    public RestBean updateReviseList(@RequestParam("userId") Integer userId,
                                     @RequestParam("reviseList[]")List<Integer> reviseList){

        return this.vocabularyService.updateReviseList(userId,reviseList);
    }


    @PostMapping("/clearReviseList")
    public RestBean clearReviseList(@RequestParam("userId") Integer userId){
         return this.vocabularyService.clearReviseList(userId);
    }


    @GetMapping("/setSchedule")
    public RestBean setSchedule(@RequestParam("userId")Integer userId,
                                @RequestParam("listId")Integer listId){

        return this.vocabularyService.setSchedule(userId,listId);
    }



}
